package com.zhao.modleclass.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhao.modleclass.Helper.RecyclerViewAdapterHelper;
import com.zhao.modleclass.R;
import com.zhao.modleclass.activity.HPType1Activity;
import com.zhao.modleclass.activity.Live_Fragment_Activity;
import com.zhao.modleclass.bean.SC_TeacherRActivityBean;

import java.util.List;

import static com.zhao.modleclass.R.layout.item_activity_sc_teacher_r;

/**
 * Created by 张昭 on 2016/12/22.
 */

public class SC_TeacherRActivityAdapter extends RecyclerViewAdapterHelper {
    private static final String TAG = "";
    private Context mContext;
    private List<SC_TeacherRActivityBean.DataBean> mList;
    private RecyclerView recyclerView;
    public SC_TeacherRActivityAdapter(Context context, List list,RecyclerView recyclerView) {
        super(context, list);
        this.mContext=context;
        this.mList=list;
        this.recyclerView=recyclerView;
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view=mInflater.inflate(R.layout.item_activity_sc_teacher_r,parent,false);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int position=recyclerView.getChildLayoutPosition(v);

                int CourseId=mList.get(position).getCourseId();
                Intent intent=new Intent();
                if(mList.get(position).getLiveType()==4){
                    intent.setClass(mContext, Live_Fragment_Activity.class);
                }else if(mList.get(position).getLiveType()==3){
                    intent.setClass(mContext,HPType1Activity.class);
                    intent.putExtra("Type",3);
                }
                intent.putExtra("imag_URL",mList.get(position).getImageUrl());
                intent.putExtra("title",mList.get(position).getTitle());
                intent.putExtra("CourseId",CourseId);
                mContext.startActivity(intent);
            }
        });
        return new MyHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof MyHolder){
            ((MyHolder) holder).textView_Title.setText(mList.get(position).getTitle());
            ((MyHolder) holder).textView_Cont.setText(mList.get(position).getTechNickName()+
            "/"+mList.get(position).getTechJobName());
            ((MyHolder) holder).textView_Titme.setText(mList.get(position).getLiveTime());
            Glide.with(mContext).load(mList.get(position).getImageUrl()).into(((MyHolder) holder).imageView_Bg);
        }



    }
    class MyHolder extends RecyclerView.ViewHolder {
        private TextView textView_Title,textView_Cont,textView_Titme;
        private ImageView imageView_Bg;
        public MyHolder(View itemView) {
            super(itemView);
            textView_Title= (TextView) itemView.findViewById(R.id.textView_activity_SC_TR_title);
            textView_Cont= (TextView) itemView.findViewById(R.id.textView_activity_SC_TR_Content);
            textView_Titme= (TextView) itemView.findViewById(R.id.textView_activity_SC_TR_Time);
            imageView_Bg= (ImageView) itemView.findViewById(R.id.imageView_activity_SC_TR);

        }
    }


}
